package com.erp.Util;

import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.Servlet;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class WebUtil {
    //获取request
    public static HttpServletRequest getRequest() {

        HttpServletRequest request = null;


        ServletRequestAttributes sra =
                (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

        request = sra.getRequest();

        return request;
    }


    //获取session
    public static HttpSession getSession() {


        HttpSession session = getRequest().getSession();


        return session;

    }
}
